package com.aisino.nmg.template;

import com.aisino.nmg.template.freemarker.FreeMarkerFactory;
import com.aisino.nmg.template.velocity.VelocityFactory;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class EngineBuilder implements Serializable {
	private transient Map<String, TemplateEngine> engineMap;

	public EngineBuilder(String classPath) {
		engineMap = new HashMap<String, TemplateEngine>();
		synchronized (this) {
			engineMap.put("freemarker", new FreeMarkerFactory(classPath));
			engineMap.put("velocity", new VelocityFactory(classPath));
		}
	}

	public TemplateEngine getTemplateEngine(String engine) {
		return engineMap.get(engine);
	}
}
